import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:klfz_flutter/book/book_list/view.dart';
import 'package:klfz_flutter/cartoon/view.dart';
import 'package:klfz_flutter/mine/view.dart';
import 'package:klfz_flutter/music/view.dart';

class MainPage extends StatefulWidget {

  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {

  int _page = 0;
  GlobalKey<CurvedNavigationBarState> _bottomNavigationKey = GlobalKey();
  final pageList = [
    BookPage(),
    MusicPage(),
    CartoonPage(),
    MinePage()
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: CurvedNavigationBar(
        key: _bottomNavigationKey,
        buttonBackgroundColor: Colors.black,
        backgroundColor: Colors.white,
        color: Colors.black,
        items: <Widget>[
          Icon(Icons.book, size: 30, color: Colors.white,),
          Icon(Icons.queue_music, size: 30, color: Colors.white),
          Icon(Icons.local_movies, size: 30, color: Colors.white),
          Icon(Icons.person, size: 30, color: Colors.white),
        ],
        onTap: (index) {
          setState(() {
            _page = index;
          });
          //Handle button tap
        },
      ),
      body: Container(
        child: pageList[_page],
        // color: Colors.blueAccent,
      )
    );
  }
}
